﻿<Cmdlet(VerbsDiagnostic.Test, "SqlConnection")>
Public Class TestSqlConnection
    Inherits PSCmdlet

    <Parameter(ValueFromPipeline:=True, Position:=0, ParameterSetName:="Single")>
    Public Property ConnectionName As String = "Default"
    <Parameter(Mandatory:=True, ParameterSetName:="All")>
    Public Property All As SwitchParameter

    Protected Overrides Sub EndProcessing()
        MyBase.EndProcessing()
        If (All.IsPresent AndAlso DBInfo.Connections.Count > 0) Then
            WriteObject(True)
        ElseIf DBInfo.Connections.ContainsKey(ConnectionName) Then
            WriteObject(True)
        Else
            WriteObject(False)
        End If
    End Sub
End Class
